<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><?php echo !empty($header['title']) ? $header['title'] : '后台管理'; ?></title>
    <link href="/houtai/css/style.css<?php echo '?r='.time(); ?>" rel="stylesheet" type="text/css" />
    
    <script src="//apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="/houtai/js/date/WdatePicker.js"></script>
    <!-- <script src="/houtai/js/layer/layer.js"></script> -->
</head>

<body class="sarchbody">
    <div class="place">
        <span>位置：</span>
        <ul class="placeul">
            <?php if (!empty($header['placeList']) && is_array($header['placeList'])): ?>
            <?php foreach ($header['placeList'] as $v): ?>
                <li>
                    <a href="<?php echo empty($v['link']) ? 'javascript:;' : ADMIN_DIR.'/'.$v['link'] ?>">
                        <?php echo $v['title']; ?>
                    </a>
                </li>   
            <?php endforeach; ?>
            <?php else: ?>
                <li>
                    <a>后台管理</a>
                </li> 
            <?php endif; ?>
        </ul>
    </div>
    

    <form  method="get" id="searchForm" class="formbody">
        <div id="usual1" class="usual">
            <?php if (isset($formItems)): ?>
                <ul class="seachform1">
                    <?php foreach ($formItems as $item): ?>
                        <?php switch ($item) : 
                                case 'br': ?>
                                </ul>
                                <ul class="seachform1">
                            <?php break; ?>
                            <?php case 'uid':   ?>
                                <li>
                                    <label>用户ID</label>
                                    <input type="text" name="uid" value="" class="scinput1"/>
                                </li>
                            <?php break; ?>
                            <?php case 'orderID':   ?>
                                <li>
                                    <label>订单ID</label>
                                    <input type="text" name="orderID" value="" class="scinput1"/>
                                </li>
                            <?php break; ?>
                            <?php case 'phone':   ?>
                                <li>
                                    <label>手机号码</label>
                                    <input type="text" name="phone" value="" class="scinput1"/>
                                </li>
                            <?php break; ?>
                            <?php case 'nickname': ?>
                                <li>
                                    <label>用户昵称</label>
                                    <input type="text" name="nickname" value="" class="scinput1"/>
                                </li>
                            <?php break; ?>
                            <?php case 'st': ?>
                                <li>
                                    <label>起始时间</label>
                                    <input type="text" class="scinput1" name="st" value="" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
                                </li>
                            <?php break; ?>
                            <?php case 'et': ?>
                                <li>
                                    <label>截至时间</label>
                                    <input type="text" class="scinput1" name="et" value="" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
                                </li>
                            <?php break; ?>
                            <?php case 'ip': ?>
                                <li>
                                    <label>IP</label>
                                    <input type="text" class="scinput1" name="ip" value="" />
                                </li>
                            <?php break; ?>
                            <?php case 'rechargecardState'://充值卡状态 ?>
                                <li>
                                    <label>充值卡状态</label>
                                    <select name="rechargecardState" class="select">
                                        <option value="-1">全部</option>
                                        <option value="0">未使用</option>
                                        <option value="1">已使用</option>
                                    </select>
                                </li>
                            <?php break; ?>

                            <?php case 'showTester': ?>
                                <li>
                                    <label>&nbsp;</label>
                                    <input type="checkbox" name="showTester" value="1" checked>
                                    显示调试账号
                                </li>
                            <?php break; ?>
                            <?php case 'showAllUser': ?>
                                <li>
                                    <label>&nbsp;</label>
                                    <input type="checkbox" name="showAllUser" value="1" >
                                    显示全部用户
                                </li>
                            <?php break; ?>
                            <?php case 'school': ?>
                                <?php if (!empty($schoolList)): ?>
                                <li>
                                    <label>学校</label>
                                    <select name="schoolID"  class="select">
                                            <option value="0">全部</option>
                                        <?php foreach ($schoolList as $v): ?>
                                            <option value="<?php echo $v['id']; ?>"><?php echo $v['name']; ?></option>
                                        <?php endforeach; ?>
                                    </select>
                                </li>
                                <?php endif; ?>
                            <?php break; ?>
                            <?php case 'tradeState': ?>
                                <?php if (!empty($tradeStateCnList)): ?>
                                <li>
                                    <label>订单状态</label>
                                    <select name="tradeState"  class="select">
                                            <option value="ALL">全部</option>
                                        <?php foreach ($tradeStateCnList as $k => $v): ?>
                                            <option value="<?php echo $k; ?>"><?php echo $v; ?></option>
                                        <?php endforeach; ?>
                                    </select>
                                </li>
                                <?php endif; ?>
                            <?php break; ?>
                            <?php default:// 通过指令创建 ?>
                                <?php if (is_array($item)): ?>
                                    <?php if (!empty($item['type'])): ?>
                                        <?php switch($item['type']):
                                                case 'text'://input[type="text"],必含'label','name'字段 ?>
                                                <li>
                                                    <label><?php echo $item['label']; ?></label>
                                                    <input type="text" name="<?php echo $item['name'] ?>" class="scinput1">
                                                </li>
                                            <?php break; ?>
                                            <?php case 'dateRange'://时间范围,必含'label','name'字段,name为键名为0,1数组 ?>
                                                <li>
                                                    <label><?php echo $item['label']; ?></label>
                                                    <input type="text" class="scinput1" name="<?php echo $item['name'][0] ?>" value="" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
                                                    <i>&nbsp;-&nbsp;</i>
                                                    <input type="text" class="scinput1" name="<?php echo $item['name'][1] ?>" value="" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
                                                </li>
                                            <?php break; ?>
                                            <?php case 'select': ?>
                                                <li>
                                                    
                                                </li>
                                            <?php break; ?>
                                        <?php endswitch; ?>
                                    <?php else: ?>
                                        <li>
                                            <?php echo $tpl->createFormItem($item); ?>
                                        </li> 
                                    <?php endif; ?>
                                 
                                <?php endif; ?>
                            <?php break;//default break ?>
                        <?php endswitch; ?>
                    <?php endforeach; ?>
                </ul>
                <ul class="seachform1" id="searchFormButtons">
                    <li class="sarchbtn" >
                        <label>&nbsp;</label>
                        <input name="" id="searchBtn" type="submit" class="scbtn" value="查询"/>
                        <input name="" id="resetBtn"  type="reset" class="scbtn1" value="重置"/>
                        <input type="hidden" name="order" value="">
                        <input type="hidden" name="sort" value="0">
                    </li>
                </ul>
            <?php endif; ?>
            <div class="formtitle">
                <span><?php echo $tableTitle; ?></span>
            </div>
            <?php if (empty($tdList)): ?>
                <h1>查无数据</h1>
            <?php else: ?>
                <table class="tablelist" id="dataTable">
                    <thead>
                        <tr>
                            <?php foreach ($thList as $th): ?>
                                <?php if (is_string($th)): ?>
                                    <th><?php echo $th; ?></th>
                                <?php else : ?>  
                                    <?php if (is_array($th)): ?>
                                        <th>
                                            <?php echo $th['text']; ?>
                                            <?php if (isset($th['order'])): ?>
                                                <i class="sort" data-order="<?php echo $th['order']; ?>">
                                                    <img src="/houtai/images/px.gif">
                                                </i> 
                                            <?php endif; ?>
                                        </th>
                                    <?php endif; ?>
                                <?php endif; ?>
                                
                            <?php endforeach; ?>
                        </tr>
                    </thead>
                    <tbody>
                       <?php foreach ($tdList as $row): ?>
                        <tr
                            <?php if ( isset($row['trData']) ): ?>
                                <?php foreach ($row['trData'] as $key => $value): ?>
                                    <?php echo 'data-',$key,'="',$value,'" '; ?>
                                <?php endforeach; ?>
                            <?php unset($row['trData']); ?>
                            <?php endif; ?>
                        >  
                               <?php foreach ($row as $td): ?>
                                <?php if (is_array($td)): ?>
                                    <td <?php echo isset($td['class']) ? 'class="'.$td['class'].'"' : ''; ?>>
                                        <?php echo isset($td['val']) ? $td['val'] : ''; ?>
                                    </td>
                                <?php else: ?>
                                    <td>
                                       <?php echo $td; ?> 
                                    </td>
                                <?php endif; ?>
                               <?php endforeach; ?>
                           </tr>
                       <?php endforeach; ?>

                    </tbody>
                </table>
                <?php if ( !empty($_pageData) )://分页 ?>
                    <div class="pagin">
                        <div class="message">
                            共<i class="blue"><?php echo $_pageData['rowCount']; ?></i>条记录,
                            当前第&nbsp;<i class="blue"><?php echo $_pageData['current']; ?>&nbsp;</i>页,
                            共&nbsp;<i class="blue"><?php echo $_pageData['pageCount']; ?>&nbsp;</i>页

                        </div>
                        <ul class="paginList">
                            <?php if ($_pageData['current']>1): ?>
                                <li class="paginItem">
                                    <a href="<?php echo $_pageData['urlPrefix'].'1'; ?>">首页</a>
                                </li>
                                <li class="paginItem">
                                    <a href="<?php echo $_pageData['urlPrefix'].($_pageData['current']-1); ?>">
                                        <span class="pagepre"></span>
                                    </a>
                                </li>
                            <?php endif; ?>
                            <?php for($i=$_pageData['min'];$i<=$_pageData['max'];$i++): ?>
                                <li class="paginItem">
                                    <?php if ($_pageData['current'] == $i): ?>
                                        <a class="paginItem current" href="javascript:;"><?php echo $i; ?></a>
                                    <?php else: ?>   
                                        <a class="paginItem" href="<?php echo $_pageData['urlPrefix'].$i; ?>"><?php echo $i; ?></a>   
                                    <?php endif; ?>
                                    
                                </li>
                            <?php endfor; ?> 
                            <?php if ($_pageData['current']<$_pageData['pageCount']): ?>
                                
                                <li class="paginItem">
                                    <a href="<?php echo $_pageData['urlPrefix'].($_pageData['current']+1); ?>">
                                        <span class="pagenxt"></span>
                                    </a>
                                </li>
                                <li class="paginItem">
                                    <a href="<?php echo $_pageData['urlPrefix'].$_pageData['pageCount']; ?>">末页</a>
                                </li>
                            <?php endif; ?>
                        </ul>
                        <div class="pagesize">
                            <label>每页显示</label>
                            <select name="pagesize" id="pagesize">
                                <option value="10">10</option>
                                <option value="20" selected>20</option>
                                <option value="50">50</option>
                                <option value="100">100</option>
                                <option value="500">100</option>
                                <option value="1000">1000</option>
                            </select>
                        </div>
                    </div>     
                <?php endif;//判断:分页 ?>
            <?php endif;//判断:有无数据 ?>

        </div>
    </form>

    <?php if ( !empty($debug) && !empty($tpl->db) && !empty($tpl->db->queries) ): ?>
       <div>
           <pre>
               <?php pr($tpl->db->queries); ?>
           </pre>
       </div> 
    <?php endif; ?>
    <script src="/houtai/js/search_tpl.js<?php echo '?r='.time(); ?>" type="text/javascript"></script>
    <?php if (isset($jsCtrl)): //运行对应的JS控制器 ?>
        <script type="text/javascript"><?php echo $jsCtrl.'()'; ?></script>
    <?php endif; ?>
</body>
    
</html>
